package com.zqk.pattern.creational.singleton;

/**
 * @Package com.zqk.pattern.creational.singleton
 * @Description:TODO
 * @Author 张乾坤
 * @Create: 2018/10/26
 * @Version 1.0
 * @Update: message
 */
public class LazySingleton {
    private static LazySingleton lazySingleton = null;

    private LazySingleton() {
        if(lazySingleton!=null){
            throw new RuntimeException("不能在生成了");
        }
    }

    public synchronized static LazySingleton getInstance() {
        if (lazySingleton == null) {
            lazySingleton = new LazySingleton();
        }
        return lazySingleton;
    }
}
